Chart for WPF and Silverlight > Chart Features > Markers and Labels > Updating Labels in Code |
You can also use code to update a label element on your form. For example, you might want to create a marker that will update a label outside the chart with its value. To achieve this, you need to listen to the DataPointChanged event on the marker.
The following code gets the marker's data point value and sets it to a TextBlock on your form:
C# |
Copy Code
|
---|---|
private void ChartPanelObject_DataPointChanged(object sender, EventArgs e) { // update label in code from marker var obj = (ChartPanelObject)sender; if (obj != null) { lbl.Text = obj.DataPoint.Y.ToString("c2"); } } |